﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
using System.Collections;

namespace mpsalaryprojectgroup
{
    public partial class NEWAnalytical : System.Web.UI.Page
    {

        String username = "";
        String loginName = "";
        protected void Page_Load(object sender, EventArgs e)
        {

            
            //clear the labels
            lblError.Text = "";
            lblError1.Text = "";

            if (!IsPostBack)
            {

                if (Session["Usename"] != null)
                {
                    username = (string)(Session["Usename"]);
                    if (username == null)
                    {
                        Response.Redirect("NEWMainPage.aspx");
                    }
                    else
                    {
                        lblUsername.Text = username;
                    }
                }
                else if (Session["UsenameLogin"] != null)
                {
                    loginName = (string)(Session["UsenameLogin"]);
                    if (loginName == null)
                    {
                        Response.Redirect("NEWMainPage.aspx");
                    }
                    else
                    {
                        lblUsername.Text = loginName;
                    }
                }
                else
                {
                    Response.Redirect("NEWMainPage.aspx");
                }

                
                    SqlConnection conn = new SqlConnection();
                    SqlCommand comm = new SqlCommand();
                    try
                    {
                        conn.ConnectionString = ConfigurationManager.ConnectionStrings["dbConn"].ToString();
                        conn.Open();

                        comm.Connection = conn;
                        comm.CommandText = "SELECT Distinct Course FROM Wages WHERE IsIndustrial LIKE '%Is Course%' ";
                        SqlDataReader dr = comm.ExecuteReader();
                        while (dr.Read())
                        {
                            Courses1DDL.Items.Add(dr["Course"].ToString());
                            Courses2DDL.Items.Add(dr["Course"].ToString());

                        }

                    }
                    catch (SqlException ex)
                    {
                        //If there is an error with the database
                        throw ex;
                    }
                    finally
                    {
                        // no matter what, run this
                        conn.Close();

                    }

                    //SqlConnection conn = new SqlConnection();
                    //SqlCommand comm = new SqlCommand();
                    try
                    {
                        conn.ConnectionString = ConfigurationManager.ConnectionStrings["dbConn"].ToString();
                        conn.Open();

                        comm.Connection = conn;
                        comm.CommandText = "SELECT Distinct Course FROM Wages WHERE IsIndustrial LIKE '%Is Industrial%' ";
                        SqlDataReader dr = comm.ExecuteReader();
                        while (dr.Read())
                        {
                            Industries1DDL.Items.Add(dr["Course"].ToString());
                            Industries2DDL.Items.Add(dr["Course"].ToString());

                        }

                    }
                    catch (SqlException ex)
                    {
                        //If there is an error with the database
                        throw ex;
                    }
                    finally
                    {
                        // no matter what, run this
                        conn.Close();

                    }
            }

            DisableBufferingOnPage();
        }
        protected void DisableBufferingOnPage()
        {
            Response.Buffer = true;
            Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);
            // set expiry date in the past
            Response.Expires = -1;
            Response.CacheControl = "no-cache";
            Response.Cache.SetNoStore();
            Response.AppendHeader("Pragma", "no-cache");
            Response.AppendHeader("Cache-Control", "no-cache");
            Response.CacheControl = "no-cache";
            Response.Expires = -1;
            Response.ExpiresAbsolute = new DateTime(1900, 1, 1);
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            //chart
            Industries1DDL.SelectedValue = "Please Select an Industry";
            Industries2DDL.SelectedValue = "Please Select an Industry";

            if (Courses1DDL.Text == "Please Select a Course")
            {
                lblError.Text = "Please Select a Course to compare";
            }

            chartInclude();
        }

        //by course
        protected void chartInclude()
        {
            
                if (Courses1DDL.SelectedValue != "Please Select a Course")
                {
                    mpsalaryprojectgroup.App_Code.Wages w = new mpsalaryprojectgroup.App_Code.Wages();


                    w.Course = Courses1DDL.SelectedValue;

                    string c = Courses1DDL.SelectedValue;
                    string c1 = Courses2DDL.SelectedValue;

                    if (MeanMedianDDL.SelectedValue == "Mean")
                    {
                        DataTable dTable = new DataTable("Table1");
                        dTable = w.GetMeanWages();

                        //blank spaces
                        foreach (DataRow row in dTable.Rows)
                        {
                            foreach (DataColumn col in dTable.Columns)
                            {
                                object cellData = row[col];
                                string d1 = cellData.ToString();
                                if (d1 == "s" || d1 == "s " || d1 == "n.a." || d1 == "n.a. " || d1 == "&nbsp;" || d1 == "-" || d1 == "nil")
                                {
                                    row[col] = '0';
                                }

                            }
                        }


                        if (Courses2DDL.SelectedValue != "Please Select a Course")
                        {

                            w.Course = Courses2DDL.SelectedValue;
                            dTable = w.GetCompareMean();



                            //blank spaces
                            foreach (DataRow row in dTable.Rows)
                            {
                                foreach (DataColumn col in dTable.Columns)
                                {
                                    object cellData = row[col];
                                    string d1 = cellData.ToString();
                                    if (d1 == "s" || d1 == "s " || d1 == "n.a." || d1 == "n.a. " || d1 == "&nbsp;" || d1 == "-" || d1 == "nil")
                                    {
                                        row[col] = '0';
                                    }

                                }
                            }
                            //Response.Write("<!--TEST123-->");
                            Response.Write("<script type='text/javascript'>");

                            Response.Write("google.load(\"visualization\", \"1\", { packages: [\"corechart\"] });");

                            Response.Write("google.setOnLoadCallback(drawChart);");

                            Response.Write("function drawChart() {");

                            Response.Write("    var data = new google.visualization.DataTable();");

                            // Add in each column you want to map into the chart

                            Response.Write("    data.addColumn('string', 'Year');");

                            Response.Write("    data.addColumn('number', 'Fresh Graduates Mean Wages " + c + "');");

                            Response.Write("    data.addColumn('number', 'Post-NS Graduates Mean Wages " + c + "');");

                            Response.Write("    data.addColumn('number', 'Fresh Graduates Mean Wages " + c1 + "');");

                            Response.Write("    data.addColumn('number', 'Post-NS Graduates Mean Wages " + c1 + "');");




                            // Code to dynamically pull # of entries to span the chart accordingly

                            int numRow = 0;

                            foreach (DataRow row in dTable.Rows)
                            {

                                numRow++;

                            }



                            Response.Write("    data.addRows(" + numRow + ");");

                            int t = 0;

                            foreach (DataRow row in dTable.Rows)
                            {

                                Response.Write("    data.setValue(" + t + ", 0, '" + Convert.ToString(row[0]) + "');");

                                Response.Write("    data.setValue(" + t + ", 1, " + Convert.ToString(row[1]) + ");");

                                Response.Write("    data.setValue(" + t + ", 2, " + Convert.ToString(row[2]) + ");");

                                Response.Write("    data.setValue(" + t + ", 3, " + Convert.ToString(row[3]) + ");");

                                Response.Write("    data.setValue(" + t + ", 4, " + Convert.ToString(row[4]) + ");");



                                t++;

                            }


                            Response.Write("");

                            // The next line declares the chart type and references the div id you added in the front end

                            if (ChartDDL.SelectedValue == "Bar Chart")
                            {
                                Response.Write("    var chart = new google.visualization.ColumnChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC' });");
                            }
                            else if (ChartDDL.SelectedValue == "Line Chart")
                            {
                                Response.Write("    var chart = new google.visualization.LineChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010', backgroundColor: '#FFFFCC' });");
                            }
                            else if (ChartDDL.SelectedValue == "Pie Chart")
                            {
                                Response.Write("    var chart = new google.visualization.PieChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC' });");
                            }
                            else
                            {
                                Response.Write("    var chart = new google.visualization.ColumnChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC' });");
                            }

                            Response.Write("}");

                            Response.Write("</script>");

                        }

                        else
                        {

                            // Push out the chart code using the datatable

                            Response.Write("<script type='text/javascript'>");

                            Response.Write("google.load(\"visualization\", \"1\", { packages: [\"corechart\"] });");

                            Response.Write("google.setOnLoadCallback(drawChart);");

                            Response.Write("function drawChart() {");

                            Response.Write("    var data = new google.visualization.DataTable();");

                            // Add in each column you want to map into the chart

                            Response.Write("    data.addColumn('string', 'Year');");

                            Response.Write("    data.addColumn('number', 'Fresh Graduates Mean Wages " + c + "');");

                            Response.Write("    data.addColumn('number', 'Post-NS Graduates Mean Wages " + c + "');");

                            // Code to dynamically pull # of entries to span the chart accordingly

                            int numRow = 0;

                            foreach (DataRow row in dTable.Rows)
                            {

                                numRow++;

                            }



                            Response.Write("    data.addRows(" + numRow + ");");

                            int i = 0;

                            foreach (DataRow row in dTable.Rows)
                            {

                                Response.Write("    data.setValue(" + i + ", 0, '" + Convert.ToString(row[0]) + "');");

                                Response.Write("    data.setValue(" + i + ", 1, " + Convert.ToString(row[1]) + ");");

                                Response.Write("    data.setValue(" + i + ", 2, " + Convert.ToString(row[2]) + ");");

                                i++;

                            }



                            Response.Write("");

                            // The next line declares the chart type and references the div id you added in the front end
                            if (ChartDDL.SelectedValue == "Bar Chart")
                            {
                                Response.Write("    var chart = new google.visualization.ColumnChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC' });");
                            }
                            else if (ChartDDL.SelectedValue == "Line Chart")
                            {
                                Response.Write("    var chart = new google.visualization.LineChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC' });");
                            }
                            else if (ChartDDL.SelectedValue == "Pie Chart")
                            {
                                Response.Write("    var chart = new google.visualization.PieChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC' });");
                            }
                            else
                            {
                                Response.Write("    var chart = new google.visualization.ColumnChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC' });");
                            }

                            Response.Write("}");

                            Response.Write("</script>");
                        }


                    }

                    else if (MeanMedianDDL.SelectedValue == "Median")
                    {

                        DataTable dTable1 = new DataTable("Table2");
                        dTable1 = w.GetMedianWages();


                        foreach (DataRow row in dTable1.Rows)
                        {
                            foreach (DataColumn col in dTable1.Columns)
                            {
                                object cellData = row[col];
                                string d1 = cellData.ToString();
                                if (d1 == "s" || d1 == "s " || d1 == "n.a." || d1 == "n.a. " || d1 == "&nbsp;" || d1 == "-" || d1 == "nil")
                                {
                                    row[col] = '0';
                                }

                            }
                        }


                        if (Courses2DDL.SelectedValue != "Please Select a Course")
                        {

                            w.Course = Courses2DDL.SelectedValue;
                            dTable1 = w.GetCompareMedian();


                            //blank spaces
                            foreach (DataRow row in dTable1.Rows)
                            {
                                foreach (DataColumn col in dTable1.Columns)
                                {
                                    object cellData = row[col];
                                    string d1 = cellData.ToString();
                                    if (d1 == "s" || d1 == "s " || d1 == "n.a." || d1 == "n.a. " || d1 == "&nbsp;" || d1 == "-" || d1 == "nil")
                                    {
                                        row[col] = '0';
                                    }

                                }
                            }


                            Response.Write("<script type='text/javascript'>");

                            Response.Write("google.load(\"visualization\", \"1\", { packages: [\"corechart\"] });");

                            Response.Write("google.setOnLoadCallback(drawChart);");

                            Response.Write("function drawChart() {");

                            Response.Write("    var data = new google.visualization.DataTable();");

                            // Add in each column you want to map into the chart

                            Response.Write("    data.addColumn('string', 'Year');");

                            Response.Write("    data.addColumn('number', 'Fresh Graduates Median Wages " + c + "');");

                            Response.Write("    data.addColumn('number', 'Post-NS Graduates Median Wages " + c + "');");

                            Response.Write("    data.addColumn('number', 'Fresh Graduates Median Wages " + c1 + "');");

                            Response.Write("    data.addColumn('number', 'Post-NS Graduates Median Wages " + c1 + "');");




                            // Code to dynamically pull # of entries to span the chart accordingly

                            int numRow = 0;

                            foreach (DataRow row in dTable1.Rows)
                            {

                                numRow++;

                            }



                            Response.Write("    data.addRows(" + numRow + ");");

                            int t = 0;

                            foreach (DataRow row in dTable1.Rows)
                            {

                                Response.Write("    data.setValue(" + t + ", 0, '" + Convert.ToString(row[0]) + "');");

                                Response.Write("    data.setValue(" + t + ", 1, " + Convert.ToString(row[1]) + ");");

                                Response.Write("    data.setValue(" + t + ", 2, " + Convert.ToString(row[2]) + ");");

                                Response.Write("    data.setValue(" + t + ", 3, " + Convert.ToString(row[3]) + ");");

                                Response.Write("    data.setValue(" + t + ", 4, " + Convert.ToString(row[4]) + ");");



                                t++;

                            }


                            Response.Write("");

                            // The next line declares the chart type and references the div id you added in the front end

                            if (ChartDDL.SelectedValue == "Bar Chart")
                            {
                                Response.Write("    var chart = new google.visualization.ColumnChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC' });");
                            }
                            else if (ChartDDL.SelectedValue == "Line Chart")
                            {
                                Response.Write("    var chart = new google.visualization.LineChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC' });");
                            }
                            else if (ChartDDL.SelectedValue == "Pie Chart")
                            {
                                Response.Write("    var chart = new google.visualization.PieChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC' });");
                            }
                            else
                            {
                                Response.Write("    var chart = new google.visualization.ColumnChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC' });");
                            }

                            Response.Write("}");

                            Response.Write("</script>");


                        }
                        else
                        {
                            // Push out the chart code using the datatable

                            Response.Write("<script type='text/javascript'>");

                            Response.Write("google.load(\"visualization\", \"1\", { packages: [\"corechart\"] });");

                            Response.Write("google.setOnLoadCallback(drawChart);");

                            Response.Write("function drawChart() {");

                            Response.Write("    var data = new google.visualization.DataTable();");

                            // Add in each column you want to map into the chart

                            Response.Write("    data.addColumn('string', 'Year');");

                            Response.Write("    data.addColumn('number', 'Fresh Graduates Median " + c + "');");

                            Response.Write("    data.addColumn('number', 'Post-NS Graduates Median " + c + "');");



                            // Code to dynamically pull # of entries to span the chart accordingly

                            int numRow = 0;

                            foreach (DataRow row in dTable1.Rows)
                            {

                                numRow++;

                            }



                            Response.Write("    data.addRows(" + numRow + ");");

                            int i = 0;

                            foreach (DataRow row in dTable1.Rows)
                            {

                                Response.Write("    data.setValue(" + i + ", 0, '" + Convert.ToString(row[0]) + "');");

                                Response.Write("    data.setValue(" + i + ", 1, " + Convert.ToString(row[1]) + ");");

                                Response.Write("    data.setValue(" + i + ", 2, " + Convert.ToString(row[2]) + ");");

                                i++;

                            }



                            Response.Write("");

                            // The next line declares the chart type and references the div id you added in the front end

                            if (ChartDDL.SelectedValue == "Bar Chart")
                            {
                                Response.Write("    var chart = new google.visualization.ColumnChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC' });");
                            }
                            else if (ChartDDL.SelectedValue == "Line Chart")
                            {
                                Response.Write("    var chart = new google.visualization.LineChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC' });");
                            }
                            else if (ChartDDL.SelectedValue == "Pie Chart")
                            {
                                Response.Write("    var chart = new google.visualization.PieChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC' });");
                            }
                            else
                            {
                                Response.Write("    var chart = new google.visualization.ColumnChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC' });");
                            }

                            Response.Write("}");

                            Response.Write("</script>");
                        }
                    }

                }
                else
                {

                    mpsalaryprojectgroup.App_Code.Wages w = new mpsalaryprojectgroup.App_Code.Wages();


                    w.Course = Industries1DDL.SelectedValue;

                    string c = Industries1DDL.SelectedValue;
                    string c1 = Industries2DDL.SelectedValue;

                    if (MeanMedianDDL.SelectedValue == "Mean")
                    {
                        DataTable dTable = new DataTable("Table1");
                        dTable = w.GetMeanWages();

                        //blank spaces
                        foreach (DataRow row in dTable.Rows)
                        {
                            foreach (DataColumn col in dTable.Columns)
                            {
                                object cellData = row[col];
                                string d1 = cellData.ToString();
                                if (d1 == "s" || d1 == "s " || d1 == "n.a." || d1 == "n.a. " || d1 == "&nbsp;" || d1 == "-" || d1 == "nil")
                                {
                                    row[col] = '0';
                                }

                            }
                        }


                        if (Industries2DDL.SelectedValue != "Please Select a Course")
                        {

                            w.Course = Industries2DDL.SelectedValue;
                            dTable = w.GetCompareMean();



                            //blank spaces
                            foreach (DataRow row in dTable.Rows)
                            {
                                foreach (DataColumn col in dTable.Columns)
                                {
                                    object cellData = row[col];
                                    string d1 = cellData.ToString();
                                    if (d1 == "s" || d1 == "s " || d1 == "n.a." || d1 == "n.a. " || d1 == "&nbsp;" || d1 == "-" || d1 == "nil")
                                    {
                                        row[col] = '0';
                                    }

                                }
                            }
                            //Response.Write("<!--TEST123-->");
                            Response.Write("<script type='text/javascript'>");

                            Response.Write("google.load(\"visualization\", \"1\", { packages: [\"corechart\"] });");

                            Response.Write("google.setOnLoadCallback(drawChart);");

                            Response.Write("function drawChart() {");

                            Response.Write("    var data = new google.visualization.DataTable();");

                            // Add in each column you want to map into the chart

                            Response.Write("    data.addColumn('string', 'Year');");

                            Response.Write("    data.addColumn('number', 'Fresh Graduates Mean Wages " + c + "');");

                            Response.Write("    data.addColumn('number', 'Post-NS Graduates Mean Wages " + c + "');");

                            Response.Write("    data.addColumn('number', 'Fresh Graduates Mean Wages " + c1 + "');");

                            Response.Write("    data.addColumn('number', 'Post-NS Graduates Mean Wages " + c1 + "');");




                            // Code to dynamically pull # of entries to span the chart accordingly

                            int numRow = 0;

                            foreach (DataRow row in dTable.Rows)
                            {

                                numRow++;

                            }



                            Response.Write("    data.addRows(" + numRow + ");");

                            int t = 0;

                            foreach (DataRow row in dTable.Rows)
                            {

                                Response.Write("    data.setValue(" + t + ", 0, '" + Convert.ToString(row[0]) + "');");

                                Response.Write("    data.setValue(" + t + ", 1, " + Convert.ToString(row[1]) + ");");

                                Response.Write("    data.setValue(" + t + ", 2, " + Convert.ToString(row[2]) + ");");

                                Response.Write("    data.setValue(" + t + ", 3, " + Convert.ToString(row[3]) + ");");

                                Response.Write("    data.setValue(" + t + ", 4, " + Convert.ToString(row[4]) + ");");



                                t++;

                            }


                            Response.Write("");

                            // The next line declares the chart type and references the div id you added in the front end

                            if (ChartDDL.SelectedValue == "Bar Chart")
                            {
                                Response.Write("    var chart = new google.visualization.ColumnChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC' });");
                            }
                            else if (ChartDDL.SelectedValue == "Line Chart")
                            {
                                Response.Write("    var chart = new google.visualization.LineChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC' });");
                            }
                            else if (ChartDDL.SelectedValue == "Pie Chart")
                            {
                                Response.Write("    var chart = new google.visualization.PieChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC' });");
                            }
                            else
                            {
                                Response.Write("    var chart = new google.visualization.ColumnChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC' });");
                            }

                            Response.Write("}");

                            Response.Write("</script>");

                        }

                        else
                        {

                            // Push out the chart code using the datatable

                            Response.Write("<script type='text/javascript'>");

                            Response.Write("google.load(\"visualization\", \"1\", { packages: [\"corechart\"] });");

                            Response.Write("google.setOnLoadCallback(drawChart);");

                            Response.Write("function drawChart() {");

                            Response.Write("    var data = new google.visualization.DataTable();");

                            // Add in each column you want to map into the chart

                            Response.Write("    data.addColumn('string', 'Year');");

                            Response.Write("    data.addColumn('number', 'Fresh Graduates Mean Wages " + c + "');");

                            Response.Write("    data.addColumn('number', 'Post-NS Graduates Mean Wages " + c + "');");

                            // Code to dynamically pull # of entries to span the chart accordingly

                            int numRow = 0;

                            foreach (DataRow row in dTable.Rows)
                            {

                                numRow++;

                            }



                            Response.Write("    data.addRows(" + numRow + ");");

                            int i = 0;

                            foreach (DataRow row in dTable.Rows)
                            {

                                Response.Write("    data.setValue(" + i + ", 0, '" + Convert.ToString(row[0]) + "');");

                                Response.Write("    data.setValue(" + i + ", 1, " + Convert.ToString(row[1]) + ");");

                                Response.Write("    data.setValue(" + i + ", 2, " + Convert.ToString(row[2]) + ");");

                                i++;

                            }



                            Response.Write("");

                            // The next line declares the chart type and references the div id you added in the front end
                            if (ChartDDL.SelectedValue == "Bar Chart")
                            {
                                Response.Write("    var chart = new google.visualization.ColumnChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, {width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC' });");
                            }
                            else if (ChartDDL.SelectedValue == "Line Chart")
                            {
                                Response.Write("    var chart = new google.visualization.LineChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC' });");
                            }
                            else if (ChartDDL.SelectedValue == "Pie Chart")
                            {
                                Response.Write("    var chart = new google.visualization.PieChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC' });");
                            }
                            else
                            {
                                Response.Write("    var chart = new google.visualization.ColumnChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC'});");
                            }

                            Response.Write("}");

                            Response.Write("</script>");
                        }


                    }

                    else if (MeanMedianDDL.SelectedValue == "Median")
                    {

                        DataTable dTable1 = new DataTable("Table2");
                        dTable1 = w.GetMedianWages();


                        foreach (DataRow row in dTable1.Rows)
                        {
                            foreach (DataColumn col in dTable1.Columns)
                            {
                                object cellData = row[col];
                                string d1 = cellData.ToString();
                                if (d1 == "s" || d1 == "s " || d1 == "n.a." || d1 == "n.a. " || d1 == "&nbsp;" || d1 == "-" || d1 == "nil")
                                {
                                    row[col] = '0';
                                }

                            }
                        }


                        if (Industries2DDL.SelectedValue != "Please Select a Course")
                        {

                            w.Course = Industries2DDL.SelectedValue;
                            dTable1 = w.GetCompareMedian();


                            //blank spaces
                            foreach (DataRow row in dTable1.Rows)
                            {
                                foreach (DataColumn col in dTable1.Columns)
                                {
                                    object cellData = row[col];
                                    string d1 = cellData.ToString();
                                    if (d1 == "s" || d1 == "s " || d1 == "n.a." || d1 == "n.a. " || d1 == "&nbsp;" || d1 == "-" || d1 == "nil")
                                    {
                                        row[col] = '0';
                                    }

                                }
                            }


                            Response.Write("<script type='text/javascript'>");

                            Response.Write("google.load(\"visualization\", \"1\", { packages: [\"corechart\"] });");

                            Response.Write("google.setOnLoadCallback(drawChart);");

                            Response.Write("function drawChart() {");

                            Response.Write("    var data = new google.visualization.DataTable();");

                            // Add in each column you want to map into the chart

                            Response.Write("    data.addColumn('string', 'Year');");

                            Response.Write("    data.addColumn('number', 'Fresh Graduates Median Wages " + c + "');");

                            Response.Write("    data.addColumn('number', 'Post-NS Graduates Median Wages " + c + "');");

                            Response.Write("    data.addColumn('number', 'Fresh Graduates Median Wages " + c1 + "');");

                            Response.Write("    data.addColumn('number', 'Post-NS Graduates Median Wages " + c1 + "');");




                            // Code to dynamically pull # of entries to span the chart accordingly

                            int numRow = 0;

                            foreach (DataRow row in dTable1.Rows)
                            {

                                numRow++;

                            }



                            Response.Write("    data.addRows(" + numRow + ");");

                            int t = 0;

                            foreach (DataRow row in dTable1.Rows)
                            {

                                Response.Write("    data.setValue(" + t + ", 0, '" + Convert.ToString(row[0]) + "');");

                                Response.Write("    data.setValue(" + t + ", 1, " + Convert.ToString(row[1]) + ");");

                                Response.Write("    data.setValue(" + t + ", 2, " + Convert.ToString(row[2]) + ");");

                                Response.Write("    data.setValue(" + t + ", 3, " + Convert.ToString(row[3]) + ");");

                                Response.Write("    data.setValue(" + t + ", 4, " + Convert.ToString(row[4]) + ");");



                                t++;

                            }


                            Response.Write("");

                            // The next line declares the chart type and references the div id you added in the front end

                            if (ChartDDL.SelectedValue == "Bar Chart")
                            {
                                Response.Write("    var chart = new google.visualization.ColumnChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC' });");
                            }
                            else if (ChartDDL.SelectedValue == "Line Chart")
                            {
                                Response.Write("    var chart = new google.visualization.LineChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010' ,backgroundColor: '#FFFFCC' });");
                            }
                            else if (ChartDDL.SelectedValue == "Pie Chart")
                            {
                                Response.Write("    var chart = new google.visualization.PieChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010' ,backgroundColor: '#FFFFCC'});");
                            }
                            else
                            {
                                Response.Write("    var chart = new google.visualization.ColumnChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC' });");
                            }

                            Response.Write("}");

                            Response.Write("</script>");


                        }
                        else
                        {
                            // Push out the chart code using the datatable

                            Response.Write("<script type='text/javascript'>");

                            Response.Write("google.load(\"visualization\", \"1\", { packages: [\"corechart\"] });");

                            Response.Write("google.setOnLoadCallback(drawChart);");

                            Response.Write("function drawChart() {");

                            Response.Write("    var data = new google.visualization.DataTable();");

                            // Add in each column you want to map into the chart

                            Response.Write("    data.addColumn('string', 'Year');");

                            Response.Write("    data.addColumn('number', 'Fresh Graduates Median " + c + "');");

                            Response.Write("    data.addColumn('number', 'Post-NS Graduates Median " + c + "');");



                            // Code to dynamically pull # of entries to span the chart accordingly

                            int numRow = 0;

                            foreach (DataRow row in dTable1.Rows)
                            {

                                numRow++;

                            }



                            Response.Write("    data.addRows(" + numRow + ");");

                            int i = 0;

                            foreach (DataRow row in dTable1.Rows)
                            {

                                Response.Write("    data.setValue(" + i + ", 0, '" + Convert.ToString(row[0]) + "');");

                                Response.Write("    data.setValue(" + i + ", 1, " + Convert.ToString(row[1]) + ");");

                                Response.Write("    data.setValue(" + i + ", 2, " + Convert.ToString(row[2]) + ");");

                                i++;

                            }



                            Response.Write("");

                            // The next line declares the chart type and references the div id you added in the front end

                            if (ChartDDL.SelectedValue == "Bar Chart")
                            {
                                Response.Write("    var chart = new google.visualization.ColumnChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC' });");
                            }
                            else if (ChartDDL.SelectedValue == "Line Chart")
                            {
                                Response.Write("    var chart = new google.visualization.LineChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010' ,backgroundColor: '#FFFFCC'});");
                            }
                            else if (ChartDDL.SelectedValue == "Pie Chart")
                            {
                                Response.Write("    var chart = new google.visualization.PieChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC' });");
                            }
                            else
                            {
                                Response.Write("    var chart = new google.visualization.ColumnChart(document.getElementById('chart-success'));");
                                Response.Write("    chart.draw(data, { width: 500, height: 350, title: 'Wages of Polytechnic graduates throughout the years of 2007 to 2010',backgroundColor: '#FFFFCC' });");
                            }

                            Response.Write("}");

                            Response.Write("</script>");
                        }
                    }

                
            }
        }

       

        protected void Button2_Click(object sender, EventArgs e)
        {
            Courses1DDL.SelectedValue = "Please Select a Course";
            Courses2DDL.SelectedValue = "Please Select a Course";

            if (Industries1DDL.Text == "Please Select an Industry")
            {
                lblError1.Text = "Please Select an Industry to compare";
            }


            chartInclude();
        }
    }

}